Re: Reduce PDF with QuartzFilter
Re: Reduce PDF with QuartzFilter
- Subject: Re: Reduce PDF with QuartzFilter
- From: Leonardo <email@hidden>
- Date: Fri, 28 Feb 2014 15:35:41 +0100
- Thread-topic: Reduce PDF with QuartzFilter
I have found the origin of the trouble.
In the NSView's drawRect method, where I draw the image, I use
CGContextBeginTransparencyLayer(context, NULL);
Draw image, Draw brackground color, Draw borders, Draw Shadow
CGContextEndTransparencyLayer(context);
Then the PDF file comes out uncompressed. Wrong.
If I omit CGContextBeginTransparencyLayer/CGContextEndTransparencyLayer
I get a well compressed PDF file.
I suppose that PDF/X-3 doesn't support TransparencyLayer.
So, is a way to save the PDF file as PDF/X-4?
Regards
-- Leonardo
> Da: Gerd Knops <email@hidden>
> Data: Thu, 27 Feb 2014 20:04:13 -0600
> A: Leonardo <email@hidden>
> Oggetto: Re: Reduce PDF with QuartzFilter
>
> What worked for me in the past was to use
>
> QuartzFilter *myFilter=[QuartzFilter quartzFilterWithURL:[NSURL
> fileURLWithPath:filterPath]];
>
> and use that straight in the options dictionary.
>
> Gerd
>
> On Feb 27, 2014, at 6:05 PM, Leonardo <email@hidden> wrote:
>
>> In the past I successfully created and used QuartzFilter from within my
>> Cocoa app for OS X and saved pdf files. But now it seems that I am missing
>> something.
>>
>> I have just created 2 filters with ColorSync Utility, one with
>> ImageJPEGCompress Compression Quality 1 (MinComp.qfilter) and one with
>> ImageJPEGCompress Compression Quality -1 (MaxComp.qfilter).
>> If I use them from within the application Preview, they work well.
>> I get a 146KB file and a 1.5MB file.
>>
>> Now I use the filters from within my app, this way:
>> filePath = [myBundle pathForResource:@"MinComp" ofType:@"qfilter"];
>> filterDict = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];
>> filter = [[QuartzFilterManager filterManager] importFilter:filterDict];
>> options = [NSDictionary dictionaryWithObject:filter forKey:@"QuartzFilter"];
>> saved = [pdfDoc pdfPath withOptions:options];
>>
>> I save 2 pdf files containing the same image I used in the app Preview (see
>> above), one using the min filter, and one using the max filter
>> The 2 PDF have the same byte size: 2.3MB. And I can't found the bug.
>>
>> I work with Xcode 5 and OS X 10.8.5. Target: OS X 10.8.
>> I have linked the libs: Quartz.framework, QuartzCore.framework,
>> AppKit.framework...
>> That's my MaxComp filter. Above it's my code. What do I miss?
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
>> "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
>> <plist version="1.0">
>> <dict>
>> <key>Domains</key>
>> <dict>
>> <key>Applications</key>
>> <true/>
>> <key>Printing</key>
>> <true/>
>> </dict>
>> <key>FilterData</key>
>> <dict>
>> <key>ColorSettings</key>
>> <dict>
>> <key>ImageSettings</key>
>> <dict>
>> <key>Compression Quality</key>
>> <real>-1</real>
>> <key>ImageCompression</key>
>> <string>ImageJPEGCompress</string>
>> <key>ImageScaleSettings</key>
>> <dict>
>> <key>ImageResolution</key>
>> <integer>300</integer>
>> <key>ImageScaleFactor</key>
>> <real>0.0</real>
>> <key>ImageScaleInterpolate</key>
>> <integer>2</integer>
>> <key>ImageSizeMax</key>
>> <integer>0</integer>
>> <key>ImageSizeMin</key>
>> <integer>0</integer>
>> </dict>
>> </dict>
>> </dict>
>> <key>PDF/X-3 Settings</key>
>> <dict>
>> <key>AddBleedBox</key>
>> <true/>
>> <key>AddTrimBox</key>
>> <true/>
>> <key>FlattenTransparency</key>
>> <true/>
>> <key>FlattenTransparencyResolution</key>
>> <array>
>> <real>300.0</real>
>> <real>300.0</real>
>> </array>
>> <key>Info</key>
>> <string></string>
>> <key>OutputCondition</key>
>> <string>CGATS TR 001 SWOP</string>
>> <key>OutputConditionIdentifier</key>
>> <string>CGATS TR 001</string>
>> <key>RegistryName</key>
>> <string>http://www.color.org</string>
>> <key>Trapped</key>
>> <true/>
>> </dict>
>> </dict>
>> <key>FilterType</key>
>> <integer>1</integer>
>> <key>Name</key>
>> <string>MaxComp</string>
>> </dict>
>> </plist>
>>
>>
>> Regards
>> -- Leonardo
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden