Page 1 of 1

DrawRect usage

Posted: Mon Feb 26, 2018 7:45 pm
by whoit
Hi -

Can you point me to an example of using DrawRect within the CoreAPI ?
Or, whatever similar methods are available - I only need to draw a simple rectangle on my pdf.

(I'm actually trying to draw a simple frame around TextBlock, in case there's another way)

Thanks.

Re: DrawRect usage

Posted: Tue Feb 27, 2018 8:45 am
by Sasha - PDF-XChange
Hello Wayne,

Here's a sample on this matter:
https://gist.github.com/Polaringu/bee53 ... 7741e8bf79

Cheers,
Alex

Re: DrawRect usage

Posted: Tue Apr 10, 2018 2:23 pm
by whoit
Hi Alex -

Do you have similar code using CoreAPI instead of Editor?
Most of the code refers to APIs that don't exist in the Core...pen, brush, drawrect, etc....

Re: DrawRect usage

Posted: Thu Apr 12, 2018 8:02 am
by Sasha - PDF-XChange
Hello Wayne,

You have referred to the DrawRect method, and the only DrawRect method that I found was the IUIX_RenderContext::DrawRect method. Thus I gave you a sample that I had.
What you need is the IPXC_ContentCreator - it does all of the drawing/output that you require. Here's a small sample, that you can modify to your needs:

Code: Select all

PXC_Rect rc;
IPXC_Document doc = CreateNewDocument(out rc);
PDFXEdit.IPXC_ContentCreator CC = doc.CreateContentCreator();
PDFXEdit.PXC_Rect rcText;
rcText.left = 100;
rcText.bottom = 600;
rcText.top = 700;
rcText.right = 300;

PDFXEdit.PXC_Rect rcBlock;
PDFXEdit.IPXC_CharFormat cf = pxcInst.CreateCharFormat();
CC.ShowTextBlock("Test Text Block Text", rcText, rcText, 0, -1, null, null, null, out rcBlock);  //draw text block
CC.SetLineWidth(2);
CC.Rect(rcBlock.left, rcBlock.bottom, rcBlock.right, rcBlock.top);
CC.StrokePath(true);
doc.Pages[0].PlaceContent(CC.Detach(), (UInt32)PDFXEdit.PXC_PlaceContentFlags.PlaceContent_After);

pdfCtl.OpenDocFrom(doc);
Cheers,
Alex

Re: DrawRect usage

Posted: Mon Apr 16, 2018 1:29 pm
by whoit
Yeah, I assumed that there was a comparable API in Core but wasn't sure of the name....thanks.

Re: DrawRect usage

Posted: Mon Apr 16, 2018 2:01 pm
by Stefan - PDF-XChange
You are welcome whoit,

Regards,
Stefan