A Very Small Editable PDF for Testing

A Small PDF

Ever wanted a small PDF file, or to tweak your own PDF for testing? Below is a very small PDF which you can paste into a text editor and save as MySmallPdf.PDF.
Two things are easy to edit:

  • The page size. Look for the line /MediaBox [0 0 612 144]. Leave the first (0,0) pair and edit the (612,144) to be (width of page,height of page) in 1/72ths of an inch.
  • One line of text. Look for the line (This is a small text editable pdf) Tj and replace the text with your own.

This is particularly helpful if you are testing http://itextpdf.com/ or itextsharp or some other PDF generator or API, and you want a couple of small identifiable test files to play with.

The Editable PDF

%PDF-1.4
1 0 obj
<< /Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj
<< /Type /Outlines
/Count 0
>>
endobj
3 0 obj
<< /Type /Pages
/Kids [4 0 R]
/Count 1
>>
endobj
4 0 obj
<< /Type /Page
/Parent 3 0 R
/MediaBox [0 0 612 144]
/Contents 5 0 R
/Resources << /ProcSet 6 0 R
/Font << /F1 7 0 R >>
>>
>>
endobj
5 0 obj
<< /Length 73 >>
stream
BT
/F1 24 Tf
100 100 Td
(This is a small text editable pdf) Tj
ET
endstream
endobj
6 0 obj
[/PDF /Text]
endobj
7 0 obj
<< /Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /MacRomanEncoding
>>
endobj
xref
0 8
0000000000 65535 f
0000000009 00000 n
0000000074 00000 n
0000000120 00000 n
0000000179 00000 n
0000000364 00000 n
0000000466 00000 n
0000000496 00000 n
trailer
<< /Size 8
/Root 1 0 R
>>
startxref
625
%%EOF

The PDF ISO32000 standard

The PDF reference is available for free from Adobe at http://www.adobe.com/content/dotcom/en/devnet/pdf/pdf_reference.html The one you want is the copy of the ISO reference at http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf

What is this svchost.exe (LocalServiceAndNoImpersonation) using all my CPU?

If you've got Win7 you can find out which actual service is using your CPU via the Resource Monitor, ResMon.exe.

On the CPU tab, the second frame down is "Services" You can right-click on the offender and stop it. Often a stop and restart will fix it, at least till next time.

svchost.exe (LocalServiceAndNoImpersonation) using about 30% of core i5..

I want to set a Windows Environment Variable for my whole user login session

Use setx to permanently set an environment variable

If you've used windows environment variables at all, you've probably wished you could set them in a command window for use in another program.
You can't change the environment of an already-running program - the environment is copied when a program starts - but you can set environments values for your user session that will be picked up by any new programs you launch with setx:

setx myvariable thenewvalue

Much easier than right-clicking to get to My Computer properties.
setx /? will also tell you about setting permanent, machine-wide and remote machine environment values.

setx comes with Windows 7 or in the Windows Resouce Kit.

How to unset a variable set with setx

setx myvariable ""

See http://support.microsoft.com/kb/195050 for more details.

A no-code routing service using .Net 4 on IIS

A year ago I was working with Waheed Hussain who pointed out that the .Net framework includes a Routing namespace which allows you to implement a service router with zero code. Literally. It's an IIS application with no code, just a web.config. Here's an example:

< ?xml version="1.0"?>
<configuration>
	<system.serviceModel>
		<routing>
			<filters>
				<filter name="MatchAll" filterType="MatchAll" />
			</filters>
			<filtertables>
				<filtertable name="MyFilterTable">
					<add filterName="MatchAllFilter" endpointName="MyDestinationEndpoint" priority="0"/>
				</filtertable>
			</filtertables>
		</routing>

		<services>
			<service behaviorConfiguration="routingConfiguration" name="System.ServiceModel.Routing.RoutingService">
				<endpoint address="destinationUrl/" binding="basicHttpBinding" name="routerEndpoint1" contract="System.ServiceModel.Routing.IRequestReplyRouter" />
			</service>
		</services>

		<client>
			<endpoint name="MyDestinationEndpoint"
					  address="https://Destination.1.Host.com/destinationUrl/"
					  binding="basicHttpBinding"
					  bindingConfiguration="basicHttpBindingWithClientCertificate"
					  behaviorConfiguration="clientEndpointCredential"
					  contract="*" />
		</client>

		<behaviors>
			<servicebehaviors>
				<behavior name="routingConfiguration">
					<routing routeOnHeadersOnly="true" filterTableName="MyFilterTable" />
					<servicedebug includeExceptionDetailInFaults="true" />
					<servicemetadata httpGetEnabled="true"/>
				</behavior>
			</servicebehaviors>
			<endpointbehaviors>
				<behavior name="clientEndpointCredential">
					<clientcredentials>
						<clientcertificate storeName="My" 
                               storeLocation="LocalMachine" 
                               x509FindType="FindBySubjectName" 
                               findValue="MyClientCertificate" />
					</clientcredentials>
				</behavior>
			</endpointbehaviors>
		</behaviors>

		<bindings>
			<basichttpbinding>
				<binding name="basicHttpBindingWithClientCertificate">
					<security mode="Transport">
						<transport clientCredentialType="Certificate"/>
					</security>
				</binding>
			</basichttpbinding>
		</bindings>

		<!-- The clever bit - activate with no code needed -->
		<servicehostingenvironment>
			<serviceactivations>
				<add relativeAddress="Destination.1.Host.com.svc" 
             service="System.ServiceModel.Routing.RoutingService, System.ServiceModel.Routing, version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
			</serviceactivations>
		</servicehostingenvironment>
	</system.serviceModel>

	<system.web>
		<compilation debug="true" targetFramework="4.0" />
	</system.web>

	<system.net>
		<settings>
			<servicepointmanager expect100Continue="false" />
		</settings>
	</system.net>
	
</configuration>