Einhugur PDF Plugin: Questions

Looking at the LibHaru documentation:
https://github.com/libharu/libharu/wiki/API%3A-Document#HPDF_SetPassword

I look like it supports password protected PDFs by setting a password, but I don’t see an option for that in the Einhugur PDF plugin documentation. Am I missing it, or is that not included in the plugin?

If not is there a plan to include that functionality in the future?

Thanks,
-Karen

Why not ask @Björn Eiríksson ? :wink:

I posted on his mailing list , but my post did not appear to be published on the list.

-karen

Another question…

I am trying to convert some code to create PDFs from a project I wrote 10 years ago using Asher Dunn’s open source REALBasic PDF classes to the Einhugur Plugin , but I am running into a problem.

Asher’s classes in some ways actually have more capabilities that either the plugin or some other Xojo solutions from a RAD standpoint (That tends to happen when someone who actually needs a reusable solution themselves builds one!)…

But I am looking to do the conversion because the Einhugur Plugin plugin has features I want to add that Asher’s class do not support … namely Table of Contents and hyperlinks… (and I think adding those to Asher’s classes is beyond my ability… the PDF Spec is MASSIVE and complex!)

In that app I need (because of space considerations/text length) to put text rotated 90 degrees into column headers…

The only thing I see in the plugin that MIGHT work is a matrix operation that rotates the whole coordinate system, but using that would be tricky I think … Am i missing something?

Looking at Asher’s code he uses the PDF Tm operator which ONLY operates on the text being drawn.

The part of the code looks like:
(code = PDF code for the object
kLF = Linefeed
me refer to his PDFText Class - his API is based is modeled on object2Ds)

[code]If Rotation = 0.0 then
code = code + “1.000 0.000 0.000 1.000 " + str(me.left) + " " + str(pageHeight - (me.top + TextAscent) )+ " Tm” + kLF
Else
Dim SRot as Double = sin(me.rotation)
Dim CRot as Double = cos(me.rotation)

If Rotation < 0.0 then
code = code + formatForPDF(CRot) + " " + formatForPDF(SRot) + " " + formatForPDF(-SRot) + " " + formatForPDF(CRot) + " " + str(me.left) + " " + str(pageHeight - (me.top + (1+SRot)TextAscent) )+ " Tm" + kLF
Else
code = code + formatForPDF(CRot) + " " + formatForPDF(SRot) + " " + formatForPDF(-SRot) + " " + formatForPDF(CRot) + " " + str(me.left+SRot
TextAscent) + " " + str(pageHeight - (me.top - (1-CRot)*TextAscent) )+ " Tm" + kLF
End iF
End if
[/code]

So is there any way to rotate just text in the plugin ? If not can it be added?

Thanks,
-karen

[quote=487070:@Karen Atkocius]So is there any way to rotate just text in the plugin ? If not can it be added?
So is there any way to rotate just text in the plugin ? If not can it be added?
[/quote]

From Google I discovered LibHaru does support text rotation:

https://github.com/libharu/libharu/blob/master/demo/text_demo.c

The example code is:

[code]
/*
* Rotating text
/
angle1 = 30; /
A rotation of 30 degrees. /
rad1 = angle1 / 180 * 3.141592; /
Calcurate the radian value. */

show_description (page, 320, ypos - 60, "Rotating text");
HPDF_Page_BeginText (page);
HPDF_Page_SetTextMatrix (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1),
            330, ypos - 60);
HPDF_Page_ShowText (page, "ABCabc123");
HPDF_Page_EndText (page);[/code]

I don’t see a Page.SetTextMatrix method in the plugin… If it is not there, can it be added?

Thanks,
-karen

[quote=487070:@Karen Atkocius]In that app I need (because of space considerations/text length) to put text rotated 90 degrees into column headers…

The only thing I see in the plugin that MIGHT work is a matrix operation that rotates the whole coordinate system, but using that would be tricky I think … Am i missing something?[/quote]
No, I don’t think you are missing anything.

The steps would be something like:
• save the graphics state
• apply the transformation
• draw the text
• restore the graphics state

You might also need to translate as well as rotate depending on which point you want to rotate around.

[quote=487077:@Kevin Gale]No, I don’t think you are missing anything.

The steps would be something like:
• save the graphics state
• apply the transformation
• draw the text
• restore the graphics state

You might also need to translate as well as rotate depending on which point you want to rotate around.[/quote]

I’ll try it that way, but it seems like supporting the Tm (text matrix) operator would be the better option for text rotation… There has to be a reason both exist! Maybe Tm is less overhead?

In any case it seems that is how the LibHaru project recommends it be done from the example code they provided.

-karen

PDF Plugin: Font BoundBox Vs Ascent and Descent question.

On the Font Class one can get the BoundingBox parameters as well as Font Ascent and Decent…

But I don’t understand the difference between BoundingBox.top and Ascent and BoundingBox.Bottom and Descent.

If I understand what I can find though google, the boundingBox.Top would be the ascent for the tallest glyph, while boundingBox.Bottom would be the lowest descender in the font… Is that right?

BUT as these methods are not measuring a specific string, why are not BoundingBox.Top and Accent the same, and the same for bottom and descent? I seem to be missing something here!

BTW in the debugger the bounding box top and bottom both have larger absolute magnitudes than Ascent and descent….

Also I have no idea what boundBox left and right are… but would like to know!

I’m trying to write some higher level layout methods on top of the plugin methods, so I need to understand how to measure things.

Thanks
-Karen

[quote=487071:@Karen Atkocius]From Google I discovered LibHaru does support text rotation:

https://github.com/libharu/libharu/blob/master/demo/text_demo.c
[/quote]

Besides rotating text without having to transform the whole coordinate system, in that demo there is an example of using HPDF_Page_SetTextMatrix to “skew” Text in either or both of the X and Y directions…

To me that sounds like one could possibly use that to skew in the X direction to produce a pseudo italic style for fonts that don’t have an italic variation.

Using that method you can also scale text in either or both of the X and Y directions as well, which can also be useful…

As I can’t seem to Email Bjorn, I hope he sees this…

If he were to only expose one more LibHaru method in his plugin, I would want it to be HPDF_Page_SetTextMatrix (which in his plugin API terms would likely be the method PDFPage.SetTextMatrix).

It looks like it could add quite a lot of capabilities that I could build on top of.

-Karen

Normally, he replies instantly to mails. But he did not respond to a mail from yesterday. Maybe he‘s on vacation. Give him some time.

Mail to the plugin list or him directly have been bouncing for me since yesterday. I’m guessing he has had a server failure.

-Karen

The domain is having problems, their rebuilding some server, its been out for almost 24 hours.

[quote=487035:@Karen Atkocius]Looking at the LibHaru documentation:
https://github.com/libharu/libharu/wiki/API%3A-Document#HPDF_SetPassword

I look like it supports password protected PDFs by setting a password, but I don’t see an option for that in the Einhugur PDF plugin documentation. Am I missing it, or is that not included in the plugin?

If not is there a plan to include that functionality in the future?
[/quote]

Before the Email issues Bjorn told me that he did not include this functionality because the encryption is not very strong…

While stronger encryption would be better, just requiring a password to open the PDF would be enough to keep non hackers from seeing the content, which is better than nothing.

That said, for me that is a nice to have not a necessity… As i said above, if Bjorn was to add only one more LibHaru method to this PDF plugin I would much rather it be HPDF_Page_SetTextMatrix. As I said Asher Dunn’s classes used the Tm operator for text rotation so from his code I can see how to use that in more than the simple C example I linked to above.

-Karen