pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clifford <cliffo...@paprika-software.com>
Subject Re: PDPattern PDFBOX-1094
Date Mon, 14 Nov 2016 10:53:17 GMT
Looking at your code you have

//TODO
         // there's no way to create something like a PDPageContentStream,
         // so we'll do it the hard way

You might call what I am about too suggest a hack but it dose work

Add too PDPageContentStream

public PDPageContentStream(PDResources resources, OutputStream outputStream)
             throws IOException
     {
         this.document = null;

         output = outputStream;
         this.resources = resources;

         formatDecimal.setMaximumFractionDigits(4);
         formatDecimal.setGroupingUsed(false);
     }

You don't need the document, and its only used in the constructor so we 
do not need it
If you are going to add resource, you want then to be added to your 
current page resource.

then in your example you can replace

os1.write("1 0 0 RG 0 0 m 10 10 l -1 9 m 1 11 l 9 -1 m 11 1 l 
s".getBytes(Charsets.US_ASCII));
os1.close();

with

PDPageContentStream pcsTp = new PDPageContentStream( 
page.getResources(),os1);

         pcsTp.setStrokingColor(255, 0, 0);
         pcsTp.moveTo(0, 0);
         pcsTp.lineTo(10, 10);
         pcsTp.moveTo(-1, 9);
         pcsTp.lineTo(1, 11);
         pcsTp.moveTo(9, -1);
         pcsTp.lineTo(11, 1);
         pcsTp.closeAndStroke();
         pcsTp.close();


You may have already thought this, but the example that you sent me, I 
think it would be a good idea if it was included with the other examples 
that comes with PDFBox, as doing Pattern, is not that obvious.



On 11/11/2016 17:59, clifford wrote:
> AAAAH the penny has finally dropped, I get it now.
>
>
> Sorry for being such a pest, it is now working perfectly ok....
>
>
> Thank you very much :) :) :)
>
>
>
> On 11/11/2016 16:21, Tilman Hausherr wrote:
>> Am 11.11.2016 um 12:38 schrieb clifford:
>>> Spoke too soon, still missing Length get message on command line.
>>>
>>> also screen looks the same as sent before, it just dose not crash now.
>>
>>
>> - Did you include a content stream into your PDTilingPattern object, 
>> like I did?
>> - Please post your smallest possible working code
>> - Please upload the result PDF to a sharehoster
>> - same for images, these can be uploaded to a image sharehoster e.g. 
>> imageshack.us or imgur.com
>>
>> Tilman
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message