Preview control

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Preview control

Post by HomerWu »

Hello,

I'm now using your operation op.document.addWatermarks to add watermark to the document. Yes, we can change the style of the watermark by setting the option value. I would like to have a preview window after changing the option value, but I do not know which one of your controls to use, or through which settings to achieve the preview function, I found your PDF-XChane Editor has the in the preview function when add watermark or other operations,it's very cool!
Who can tell me how to achieve the kind of preview function of your product?

The attachment 'PDF-XChaneg Editor.png' is a screenshot of your product and 'my application.png' is a screenshot of my application.

Thanks.
Attachments
my application.png
PDF-XChaneg Editor.png
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Preview control

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

Basically you have two choices here:
1) Add the IPXV_Control on form and use it as a preview. You can use the navigation pane on the bottom to switch pages.
2) You can use the IPXV_PagesPreviewCtl to initialize some control on a windows form as preview (the one you see in the Watermarks Dialog). Though you will have to implement the top information bar and the navigation bar for yourself.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Preview control

Post by HomerWu »

Hello Sasha,

Thank you for your quick reply,you provided me two solutions, I think the first method is better. But can you tell me how to add the control? I found that the controls I added on my main interface is AxPXV_Control(have a look at the attachment).

a lot thanks.
Attachments
control.png
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Preview control

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

That's the same Control that you have on your main interface.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Preview control

Post by HomerWu »

Hello Sasha,

Thank you for your help,i'll have a try.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Preview control

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Preview control

Post by HomerWu »

Hello Sasha,

I dragged a Edit Control(AxPDFXEdit.AxPXV_Control) to a new form,and passed the IPXC_Document as a parameter to it before opening the new form,but i found it can not open the IPXC_Document successfully:cry: .It seems that the IPXC_Document is being used by the Main form,just have a look at my source code below:

Code: Select all

////////////////////////////////////////////////////////////Main Form

private void button1_Click(object sender, EventArgs e)
{
	Form2 f2 = new Form2(this.pdfCtl.Doc.CoreDoc);
	//this.pdfCtl.Doc.Close();
	f2.ShowDialog();
}


////////////////////////////////////////////////////////////New Form	
		
 private PDFXEdit.IPXC_Document _doc = null;
/// <summary>
/// 文档对象
/// </summary>
private PDFXEdit.IPXC_Document PDFDoc
{
	get { return _doc; }
	set { _doc = value; }
}

public Form2(PDFXEdit.IPXC_Document doc)
{
	this.PDFDoc = doc;
	InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
	this.pdfCtl.OpenDocFrom(this.PDFDoc);
}
i want to show the doc at the new Form for preview without close the source doc,do you have any way to do that?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Preview control

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

Then it would be better to use the Preview Control you've mentioned before. Here's the code sample:
PreviewCtrl(1).zip
(131.81 KiB) Downloaded 93 times
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Preview control

Post by HomerWu »

Hello Sasha,

Thank you for your reply,the demo is useful to me.But I met another trouble,My steps is:
1.Open a pdf with a PDF-XChange Editor Control,
2.Set IPXC_Document the cas the value of pagesPreviewCtr.Doc
3.Update the pagesPreviewCtr.Doc(addbackgroup)
the pagesPreviewCtr.Doc has not changed,but the IPXC_Document was changed. :cry:

Code: Select all

        private void button1_Click(object sender, EventArgs e)
        {
            previewCtrl1.pagesPreviewCtl.Doc = this.pdfCtl.Doc.CoreDoc;
        }

        private void Test_FormClosed(object sender, FormClosedEventArgs e)
        {
            inst.Shutdown(0);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            PDFXEdit.PXV_Inst Inst = new PXV_Inst();
            int nID = Inst.Str2ID("op.document.addBackground", false);
            PDFXEdit.IOperation Op = Inst.CreateOp(nID);
            var input = Op.Params.Root["Input"];
            input.v = previewCtrl1.pagesPreviewCtl.Doc;
            PDFXEdit.ICabNode options = Op.Params.Root["Options"];
            options["PagesRange.Type"].v = "All";
            options["Type"].v = 0; //Color
            PDFXEdit.IAUX_Inst aInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension("AUX");
            PDFXEdit.IColor clr = aInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
            clr.SetRGB(1.0f, 0.0f, 1.0f);
            options["Color"].v = clr.Value; //Color
            Op.Do();
        }
I have upload the source code to you,may you please help to update the pagesPreviewCtr.Doc instead of PDF-XChange Editor Control.Doc.CoreDoc?
Attachments
PreviewCtrl.rar
(2.08 MiB) Downloaded 77 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Preview control

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

That behavior happens because the Preview Control does not know that it should refresh it's UI. To do that, you will have to Invalidate Pages:

Code: Select all

for (uint i = 0; i < previewCtrl1.pagesPreviewCtl.Doc.Pages.Count; i++)
{
	previewCtrl1.pagesPreviewCtl.InvalidatePage(i);
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Preview control

Post by HomerWu »

Hello Sasha,

I invalidated the pages after i update the pagesPreviewCtr.Doc,it works now,thank you a lot. :P
But,i found the IPXC_Document in the PDFXChange Editor Control changed too :cry: ,do you have any way to not do this?
i just want to update the pagesPreviewCtr.Doc.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Preview control

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

Well, then you won't have to use the IPXV_Document's IPXC_Document but open a separate IPXC_Document from the same file by using the IPXC_Inst only. Then you will need to pass that document to the Preview Control. After that, when you will give the Preview Control's document to the operation - the document that you have in your IPXV_Control won't be modified.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
HomerWu
User
Posts: 91
Joined: Fri Nov 25, 2016 8:19 am

Re: Preview control

Post by HomerWu »

Hello Sasha,

As you said,i created a usercontrol for preview my document,It worked well before,but now it displaied a error during the usercontrol creating (sometimes):cry: ,i have never edit it,could you please have a look at my code and find where i was wrong?
the attachment is my sourcecode and the error info.
Attachments
Attachment.rar
(38.43 KiB) Downloaded 77 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Preview control

Post by Sasha - Tracker Dev Team »

Hello HomerWu,

We'll need a sample project that recreates this problem - then we can advice further.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply